package pets;

import java.awt.BorderLayout;
import java.util.ArrayList;

import javax.swing.*;

public class Store extends JFrame{

	JLabel name;
	JTextField nameInput;
	JPanel nameHolder;
	
	JLabel age;
	JTextField ageInput;
	JPanel ageHolder;
	
	JLabel type;
	JTextField typeInput;
	JPanel typeHolder;
	
	JPanel outer;
	JTextField list;
	JPanel listHolder;
	
	
	
	ArrayList<Pet> pets = new ArrayList();
	
	public void setUp()
	{
		BorderLayout nameLayout = new BorderLayout();
		BorderLayout ageLayout = new BorderLayout();
		BorderLayout typeLayout = new BorderLayout();
		BorderLayout listLayout = new BorderLayout();
		
		name = new JLabel("Name: ");
		nameInput = new JTextField(5);
		nameHolder = new JPanel();
		age = new JLabel("Age: ");
		ageInput = new JTextField(5);
		ageHolder = new JPanel();
		type = new JLabel("Type: ");
		typeInput = new JTextField(5);
		typeHolder = new JPanel();
		list = new JTextField(50);
		listHolder = new JPanel();
		outer = new JPanel();
		nameHolder.add(name, nameLayout.NORTH);
		nameHolder.add(nameInput, nameLayout.SOUTH);
		ageHolder.add(age, ageLayout.NORTH);
		ageHolder.add(ageInput, ageLayout.SOUTH);
		typeHolder.add(type, typeLayout.NORTH);
		typeHolder.add(typeInput, typeLayout.SOUTH);
		list.setSize(200,200);
		listHolder.add(list);
	}
	
	
	public void addPet(Pet inserted)
	{
		pets.add(inserted);
	}

	
	public Pet getPet(int indexNum)
	{
		return(pets.get(indexNum));
	}
	
	public boolean removePet(Pet gone)
	{
		return pets.remove(gone);
	}
	
	public static void main(String[] args)
	{
		// TODO Auto-generated method stub
		Store s1 = new Store();
		s1.setSize(600, 500);
		s1.setVisible(true);
		Velociraptor fred = new Velociraptor(42,"Fred",false);
		System.out.println(fred.getName()+":");
		fred.meow();
		fred.eat();
		fred.talk();
		fred.die();
		s1.addPet(fred);
		Goblin george = new Goblin(32,"George",true);
		System.out.println(george.getName()+":");
		george.noise();
		george.eat();
		george.talk();
		george.die();
		s1.addPet(george);
		System.out.println((Velociraptor)s1.getPet(0));
		System.out.println((Goblin)s1.getPet(1));
		
		
	}
	
	public Store()
	{
		BorderLayout outerLayout = new BorderLayout();
		this.setUp();
		this.add(nameHolder, outerLayout.WEST);
		this.add(ageHolder, outerLayout.NORTH);
		this.add(typeHolder, outerLayout.EAST);
		this.add(list, outerLayout.CENTER);
	}

}
